package ui.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fy.fyzf.R;
import com.fy.fyzf.base.BaseActivity;
import com.fy.fyzf.base.BasePresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ExchangeResultActivity extends BaseActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.right)
    TextView right;
    @BindView(R.id.tv_ok)
    TextView tvOk;
    @BindView(R.id.tv_result)
    TextView tvResult;
    private boolean status;
    private Integer mallId;

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_exchange_result;
    }

    @Override
    public void initView() {
        super.initView();
        back.setVisibility(View.GONE);
        right.setVisibility(View.VISIBLE);
        right.setTextColor(Color.RED);
        right.setText("完成");
    }

    @Override
    public void initData() {
        super.initData();
        status = getIntent().getBooleanExtra("status", false);
        mallId = getIntent().getIntExtra("id", -1);
        if (status) {
            setTitleName("兑换成功");
            tvResult.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.mipmap.icon_success), null, null);
            tvResult.setText("兑换成功");
            tvOk.setText("立即使用");
        } else {
            setTitleName("兑换失败");
            tvResult.setText("您的积分不足");
            tvOk.setText("获取积分");
            tvResult.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.mipmap.icon_fail), null, null);
        }
    }

    @OnClick({R.id.right, R.id.tv_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.right:
                finish();
                break;
            case R.id.tv_ok:
                if (status) {
                    Intent intent = new Intent(ExchangeResultActivity.this, ExChangeDetailActivity.class);
                    intent.putExtra("id", mallId);
                    startActivity(intent);
                }
                break;
        }
    }
}